﻿package {
   import flash.display.MovieClip;
	public class Test extends MovieClip {
      public function Test() {
      }
	}
}

function dumpBitmap(bitmap: BitmapData): void {
   var _loc2_: int = 0;
   while(_loc2_ < bitmap.width)
   {
      var _loc1_: int = 0;
      while(_loc1_ < bitmap.height)
      {
         trace("// bitmap.getPixel32(" + _loc2_ + ", " + _loc1_ + ")");
         trace(bitmap.getPixel32(_loc2_,_loc1_));
         _loc1_ = _loc1_ + 1;
      }
      _loc2_ = _loc2_ + 1;
   }
}

import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.ByteArray;

var bitmap: BitmapData = new BitmapData(10.5,10.5,false,4294967295);
trace("// bitmap");
trace(bitmap);
trace("// bitmap.width");
trace(bitmap.width);
trace("// bitmap.height");
trace(bitmap.height);
trace("// bitmap.rect");
trace(bitmap.rect.toString());
trace("// bitmap.transparent");
trace(bitmap.transparent);
bitmap = new BitmapData(3,3,true,4294967295);
bitmap.setPixel32(0,0,4294967295);
trace("// getPixel32(0, 0) after setPixel32(0, 0, 0xffffffff)");
trace(bitmap.getPixel32(0,0));
trace("// getPixel(0, 0)");
trace(bitmap.getPixel(0,0));
bitmap.setPixel32(0,0,2164260863);
trace("// getPixel32(0, 0) after setPixel32(0, 0, 0x80ffffff)");
trace(bitmap.getPixel32(0,0));
trace("// getPixel(0, 0)");
trace(bitmap.getPixel(0,0));
bitmap.setPixel(0,0,12303291);
trace("// getPixel32(0, 0) after setPixel(0, 0, 0xBBBBBB)");
trace(bitmap.getPixel32(0,0));
trace("// getPixel(0, 0)");
trace(bitmap.getPixel(0,0));
bitmap.setPixel32(0,0,16777215);
trace("// getPixel32(0, 0) after setPixel32(0, 0, 0x00ffffff)");
trace(bitmap.getPixel32(0,0));
trace("// getPixel(0, 0)");
trace(bitmap.getPixel(0,0));
trace("// get/set pixel with transparent = false");
bitmap = new BitmapData(3,3,false,4294967295);
bitmap.setPixel32(0,0,4294967295);
trace("// getPixel32(0, 0) after setPixel32(0, 0, 0xffffffff)");
trace(bitmap.getPixel32(0,0));
trace("// getPixel(0, 0)");
trace(bitmap.getPixel(0,0));
bitmap.setPixel32(0,0,2164260863);
trace("// getPixel32(0, 0) after setPixel32(0, 0, 0x80ffffff)");
trace(bitmap.getPixel32(0,0));
trace("// getPixel(0, 0)");
trace(bitmap.getPixel(0,0));
bitmap.setPixel(0,0,12303291);
trace("// getPixel32(0, 0) after setPixel(0, 0, 0xBBBBBB)");
trace(bitmap.getPixel32(0,0));
trace("// getPixel(0, 0)");
trace(bitmap.getPixel(0,0));
bitmap.setPixel32(0,0,16777215);
trace("// getPixel32(0, 0) after setPixel32(0, 0, 0x00ffffff)");
trace(bitmap.getPixel32(0,0));
trace("// getPixel(0, 0)");
trace(bitmap.getPixel(0,0));
var src: BitmapData = new BitmapData(2,2,true,4294967295);
var dest: BitmapData = new BitmapData(2,2,true,4294967295);
var pnt: Point = new Point(0,0);
src.setPixel32(0,0,4294901760);
src.setPixel32(1,0,4278255360);
src.setPixel32(0,1,4278190335);
src.setPixel32(1,1,303174162);
dumpBitmap(src);
trace("// dest.copyChannel(src, src.rect, pnt, 1, 1)");
dest.copyChannel(src,src.rect,pnt,1,1);
dumpBitmap(dest);
dest.dispose();
src = new BitmapData(2,2,true,4294967295);
trace("// fillRect(src.rect, 0xFF121212");
src.fillRect(src.rect,4279374354);
dumpBitmap(src);
src.dispose();
src = new BitmapData(2,2,true,4294967295);
trace("// fillRect(src.rect, 0xFF121212");
src.fillRect(src.rect,4279374354);
dumpBitmap(src);
var rect: Rectangle = new Rectangle(1,1,1,1);
trace("// fillRect({x: 1, y: 1, width: 1, height: 1}, 0xFF242424");
src.fillRect(src.rect,4280558628);
dumpBitmap(src);
rect = new Rectangle(-10,1,1,1);
trace("// fillRect({x: -10, y: 1, width: 1, height: 1}, 0xF3243434");
src.fillRect(src.rect,4079236148);
dumpBitmap(src);
rect = new Rectangle(0,1,100,100);
trace("// fillRect({x: 0, y: 1, width: 100, height: 100}, 0xFF424242");
src.fillRect(src.rect,4282532418);
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
var i: int = 0;
while(i < 32)
{
   var color: int = i << 24 | 16777215;
   src.fillRect(src.rect,color);
   trace("// src.getPixel32(0, 0) alpha = " + i);
   trace(src.getPixel32(0,0).toString(16));
   i++;
}
src.dispose();
var disposed: BitmapData = new BitmapData(1,1,true,4294967295);
disposed.dispose();
var flood_filled: BitmapData = new BitmapData(2,2,true,4294967295);
flood_filled.floodFill(0,0,4289440683);
dumpBitmap(flood_filled);
src = new BitmapData(1,1,true,4294967295);
trace("// getPixel (-1, -1)");
trace(src.getPixel(-1,-1));
trace("// getPixel (10, 10)");
trace(src.getPixel(10,10));
src = new BitmapData(1,1,true,4294967295);
trace("// setPixel32 (-1, -1, 0xFFFF00FF)");
src.setPixel32(-1,-1,4294902015);
trace("// getPixel32(0, 0)");
trace(src.getPixel32(0,0));
trace("// setPixel32 (0, 0, 0xFF00FF00)");
src.setPixel32(0,0,4278255360);
trace("// getPixel32(0, 0)");
trace(src.getPixel32(0,0));
src = new BitmapData(1,1,true,4294967295);
trace("// setPixel (0, 0, 0xFF00FF00)");
src.setPixel(0,0,4278255360);
trace("// getPixel32(0, 0)");
trace(src.getPixel32(0,0));
trace("// setPixel (-1, -1, 0xFFFF00FF)");
src.setPixel(-1,-1,4294902015);
trace("// getPixel32(0, 0)");
trace(src.getPixel32(0,0));
var scrol: BitmapData = new BitmapData(5,5,true,4294967295);
scrol.setPixel32(2,2,4278255360);
dumpBitmap(scrol);
scrol.scroll(1,0);
dumpBitmap(scrol);
scrol.scroll(0,1);
dumpBitmap(scrol);
scrol.scroll(1,1);
dumpBitmap(scrol);
scrol.scroll(-1,0);
dumpBitmap(scrol);
scrol.scroll(0,-1);
dumpBitmap(scrol);
scrol.scroll(-1,-1);
dumpBitmap(scrol);
scrol.scroll(0,0);
dumpBitmap(scrol);
scrol.setPixel32(4,4,4278255360);
scrol.scroll(100,100);
dumpBitmap(scrol);
scrol.setPixel32(4,4,4278255360);
scrol.scroll(-100,-100);
dumpBitmap(scrol);
src = new BitmapData(1,1,true,4294967295);
trace("// floodFill (-1, -1, 0xFFFF00FF)");
src.floodFill(-1,-1,4294902015);
dumpBitmap(src);
trace("// floodFill (0, 0, 0xFF00FF00)");
src.floodFill(0,0,4278255360);
dumpBitmap(src);
trace("// noise with channelOptions 1|4");
src.noise(0,1,255,5,false);
var x: int = src.getPixel32(0,0);
var b: int = x & 255;
var g: int = x >> 8 & 255;
var r: int = x >> 16 & 255;
var a: int = x >> 24 & 255;
trace("a: " + (a != 255) + ", r: " + (r > 0) + ", g:" + (g > 0) + ", b:" + (b > 0));
trace("// noise with channelOptions 2");
src.noise(0,1,255,2,false);
x = src.getPixel32(0,0);
b = x & 255;
g = x >> 8 & 255;
r = x >> 16 & 255;
a = x >> 24 & 255;
trace("a: " + (a != 255) + ", r: " + (r > 0) + ", g:" + (g > 0) + ", b:" + (b > 0));
trace("// noise with channelOptions 8");
src.noise(0,1,255,8,false);
x = src.getPixel32(0,0);
b = x & 255;
g = x >> 8 & 255;
r = x >> 16 & 255;
a = x >> 24 & 255;
trace("a: " + (a != 255) + ", r: " + (r > 0) + ", g:" + (g > 0) + ", b:" + (b > 0));
trace("// noise with channelOptions 8, grayScale true");
src.noise(0,1,255,8,true);
x = src.getPixel32(0,0);
b = x & 255;
g = x >> 8 & 255;
r = x >> 16 & 255;
a = x >> 24 & 255;
trace("a: " + (a != 255) + ", r: " + (r > 0) + ", g:" + (g > 0) + ", b:" + (b > 0));
trace("// noise with channelOptions 1, grayScale true");
src.noise(0,1,255,1,true);
x = src.getPixel32(0,0);
b = x & 255;
g = x >> 8 & 255;
r = x >> 16 & 255;
a = x >> 24 & 255;
trace("a: " + (a != 255) + ", r: " + (r > 0) + ", g:" + (g > 0) + ", b:" + (b > 0));
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, ColorTransform(0, 0, 0, 0, 0, 0, 0, 0))");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,0,0,0,0,0,0));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, ColorTransform(0.5, 0.5, 0.5, 0.5, 0, 0, 0, 0))");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0.5,0.5,0.5,0.5,0,0,0,0));
x = src.getPixel32(0,0);
b = x & 255;
g = x >> 8 & 255;
r = x >> 16 & 255;
a = x >> 24 & 255;
trace("a: " + a + ", r: " + r + ", g:" + g + ", b:" + b);
dumpBitmap(src);
src = new BitmapData(1,1,true,4278190080);
trace("// src.colorTransform(src.rect, ColorTransform(0, 0, 0, 0, 32, 32, 32, 32))");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,0,0,32,32,32,32));
x = src.getPixel32(0,0);
b = x & 255;
g = x >> 8 & 255;
r = x >> 16 & 255;
a = x >> 24 & 255;
trace("a: " + a + ", r: " + r + ", g:" + g + ", b:" + b);
dumpBitmap(src);
src = new BitmapData(2,2,true,4294967295);
trace("// src.colorTransform({x: -1, y: -1, width: 1, height: 1}, ColorTransform(0, 0, 0, 0, 0, 0, 0, 0))");
src.colorTransform(new Rectangle(-1,-1,1,1),new flash.geom.ColorTransform(0,0,0,0,0,0,0,0));
dumpBitmap(src);
src = new BitmapData(2,2,true,4294967295);
trace("// src.colorTransform({x: 0, y: 0, width: 3, height: 3}, ColorTransform(0, 0, 0, 0, 0, 0, 0, 0))");
src.colorTransform(new Rectangle(0,0,3,3),new flash.geom.ColorTransform(0,0,0,0,0,0,0,0));
dumpBitmap(src);
src = new BitmapData(2,2,true,4294967295);
trace("// src.colorTransform({x: 0, y: 0, width: 2, height: 2}, ColorTransform(0, 0, 0, 0, 0, 0, 0, 0))");
src.colorTransform(new Rectangle(0,0,2,2),new flash.geom.ColorTransform(0,0,0,0,0,0,0,0));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {redMultiplier: 1})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(1));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {greenMultiplier: 1})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,1));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {blueMultiplier: 1})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,1));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {alphaMultiplier: 1})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,0,1));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {redMultiplier: 0, greenMultiplier: 0, blueMultiplier: 0, alphaMultiplier: 0})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,0,0));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {redMultiplier: 0, greenMultiplier: 0, blueMultiplier: 0, alphaMultiplier: 0, redOffset: 0})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,0,0,0));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {redMultiplier: 0, greenMultiplier: 0, blueMultiplier: 0, alphaMultiplier: 0, redOffset: 0, greenOffset: 0})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,0,0,0,0));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {redMultiplier: 0, greenMultiplier: 0, blueMultiplier: 0, alphaMultiplier: 0, redOffset: 0, greenOffset: 0, blueOffset: 0})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,0,0,0,0,0));
dumpBitmap(src);
src = new BitmapData(1,1,true,4294967295);
trace("// src.colorTransform(src.rect, {redMultiplier: 0, greenMultiplier: 0, blueMultiplier: 0, alphaMultiplier: 0, redOffset: 0, greenOffset: 0, blueOffset: 0, alphaOffset: 0})");
src.colorTransform(src.rect,new flash.geom.ColorTransform(0,0,0,0,0,0,0,0));
dumpBitmap(src);
src = new BitmapData(3,3,true,4294967295);
src.setPixel32(0,0,4278255360);
trace("// src.getColorBoundsRect(0xFFFFFFFF, 0xFFFFFFFF, true)");
trace(src.getColorBoundsRect(4294967295,4294967295,true));
trace("// src.getColorBoundsRect(0xFFFFFFFF, 0xFFFFFFFF, false)");
trace(src.getColorBoundsRect(4294967295,4294967295,false));
src.setPixel32(1,1,4278255360);
trace("// src.getColorBoundsRect(0xFFFFFFFF, 0xFFFFFFFF, true)");
trace(src.getColorBoundsRect(4294967295,4294967295,true));
trace("// src.getColorBoundsRect(0xFFFFFFFF, 0xFFFFFFFF, false)");
trace(src.getColorBoundsRect(4294967295,4294967295,false));
src.setPixel32(0,0,4294967295);
trace("// src.getColorBoundsRect(0xFFFFFFFF, 0xFFFFFFFF, true)");
trace(src.getColorBoundsRect(4294967295,4294967295,true));
trace("// src.getColorBoundsRect(0xFFFFFFFF, 0xFFFFFFFF, false)");
trace(src.getColorBoundsRect(4294967295,4294967295,false));
src.setPixel32(1,1,536870912);
trace("// src.getColorBoundsRect(0xFF000000, 0x00000000, false)");
trace(src.getColorBoundsRect(4278190080,0,false));
trace("// src.getColorBoundsRect(0xFF000000, 0x00000000, true)");
trace(src.getColorBoundsRect(4278190080,0,true));
trace("// src.getColorBoundsRect(0, 0)");
trace(src.getColorBoundsRect(0,0));
src = new BitmapData(2,2,true,4294967295);
src.setPixel32(0,0,4294901760);
src.setPixel32(1,0,4278255360);
src.setPixel32(0,1,4278190335);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 1, 1)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),1,1);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(1, 1), 1, 1)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(1,1),1,1);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(-1, -1), 1, 1)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(-1,-1),1,1);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, {x: 0, y: 0}, 1, 1)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),1,1);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 1, 2)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),1,2);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 1, 4)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),1,4);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 1, 8)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),1,8);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 2, 1)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),2,1);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 2, 4)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),2,4);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 2, 8)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),1,8);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 2, 2)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),2,2);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 4, 1)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),4,1);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 4, 2)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),4,2);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 4, 4)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),4,4);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 4, 8)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),4,8);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 8, 1)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),8,1);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 8, 2)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),8,2);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 8, 4)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),8,4);
dumpBitmap(dest);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 8, 8)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),8,8);
dumpBitmap(dest);
dest = new BitmapData(2,2,true,4278190080);
trace("// dest.copyChannel(src, src.rect, Point(0, 0), 1, 1)");
dest = new BitmapData(2,2,true,4278190080);
dest.copyChannel(src,src.rect,new Point(0,0),1,1);
dumpBitmap(dest);
trace("// dest.setPixels(new Rectangle(0,1,2,1), ba=[4278190080,2]");
src = new BitmapData(2,2,true,4294967295);
var ba: ByteArray = new ByteArray();
ba.writeUnsignedInt(4278190080);
ba.writeUnsignedInt(2);
ba.position = 0;
src.setPixels(new Rectangle(0,1,2,1), ba);
dumpBitmap(src);
trace("// dest.setPixels(new Rectangle(0,1,2,1), ba=[4278190080,2], no transperancy");
src = new BitmapData(2,2,false,4294967295);
ba = new ByteArray();
ba.writeUnsignedInt(4281545523);
ba.writeUnsignedInt(2);
ba.position = 0;
src.setPixels(new Rectangle(0,1,2,1), ba);
dumpBitmap(src);
trace("// dest.setPixels(new Rectangle(0,1,2,1), ba=[4278190080]");
src = new BitmapData(2,2,true,4294967295);
ba = new ByteArray();
ba.writeUnsignedInt(4278190080);
ba.position = 0;
try {
   src.setPixels(new Rectangle(0,1,2,1), ba);
}
catch (e) {
   trace(e);
   dumpBitmap(src);
}